<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
   <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
   <script type="text/javascript">
	$(document).ready(function(){
		var checkDupliEmail=false;
					$("input[name=checkEmail]").click(function(){ 
						//<input type="button" name="check" value="중복체크" onclick="idCheck()">
						var email=$("input[name=email]").val(); 
						var id = $("input[name=id]").val(); 
						// <input type="text" name="email">
						$.ajax({
							type:"POST",
							url:"isExistEmail.inven", //url 을 노출시키지 않는다.
							data:"email="+email+"&id="+id,  //data:"email="+email
							dataType:"json", 
							success:function(jsonData){
								//alert( jsonData);
								if(jsonData!=0){
									$("#checkEmail").html("<font color='red'>중복된 이메일 입니다!</font>");
									// <span id="checkEmail"></span>
								}else{
									if($("#email").val()==""){
										$("#checkEmail").html("<font color='red'>이메일을 입력해주세요!</font>");
										return false;
									}
									$("#checkEmail").html("<font color='red'>사용가능한 이메일입니다.</font>");
									checkDupliEmail=true;
								}
							}
						}); //ajax
					});//click
		$("#updateForm").submit(function(){
			if(checkDupliEmail==false){
				alert("이메일 중복 체크를 하세요");
				return false;
			}
	
	 }); //document
	 $("#deletebtn").click(function(){
			//alert("체크");
			if(confirm("탈퇴 하시겠습니까?")){
				location.href="secessionMember.inven?id=${sessionScope.mvo.id}";
			}
	 
		});//공란체크	
	 
	 }); //document

</script>
<div class="container">
<h3 align="center">회원정보수정</h3>

<br>
<form id="updateForm" name="updateForm" enctype="multipart/form-data" action="updateInven.inven" method="post"
			onsubmit="return checkForm()">
			<input type="hidden" name="id" id="id" value="${sessionScope.mvo.id}">
			<table style="margin: auto;">
				<tr>
					<td style="width: 20%;">PASSWORD</td>
					<td colspan="2"><input style="width: 500px; height: 40px;" type="password" name="password" id="password" value="${requestScope.vo.password }"></td>
				</tr>
				<tr>
					<td>NAME</td>
					<td colspan="2"><input style="width: 500px; height: 40px;" type="text" name="name" id="name" value="${requestScope.vo.name }"></td>
				</tr>
				<tr>
					<td>PHONE</td>
					<td colspan="2"><input style="width: 500px; height: 40px;" type="text" name="phone" id="phone" value="${requestScope.vo.phone }"></td>
				</tr>
				<tr>
					<td>EMAIL</td>
					<td colspan="2"><input style="width: 500px; height: 40px;" type="text" name="email" id="email" value="${requestScope.vo.email }"></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input class="login_button" type="button" name="checkEmail" value="중복체크" onclick="checkEmail()"></td>
					<td><span id="checkEmail"></span></td>
				</tr>
				<tr>
					<td>PROFILE</td>
					<td colspan="2"><input style="width: 500px; height: 40px;" type="text" name="profile" id="profile" value="${requestScope.vo.profile }"></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><img height="200" src="userpics/${sessionScope.mvo.saveImage }"></td>
					<td><input type="file" name="uploadFile" id="uploadFile"></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input class="login_button" type="submit" value="회원정보수정"></td>
					<td><input class="login_button" type="button" value="회원탈퇴" id="deletebtn"></td>
				</tr>
			</table>
		</form>
</div>